<?php
namespace app\api\validate;

use think\Validate;

class Section extends Validate
{
    protected $rule =   [
        'title' => 'require|max:30',
        'chapter_id' => 'require|number|notin:0',
        'content' => 'require',
        'status' => 'require|in:0,1',
        'id' => 'require|number|notin:0',
    ];
    
    protected $message  =   [
        'title.require' => '标题不能为空',
        'chapter_id.require' => '缺失必要参数',
        'chapter_id.number' => '章节id参数错误',
        'chapter_id.notin' => '章节id参数错误',
        'title.max' => '标题长度不能超过30个字符',
        'id.require' => '缺失必要参数',
        'id.number' => 'id参数错误',
        'id.notin' => 'id参数错误',
        'status.require' => '状态值不能为空',
        'status.in' => '状态值参数错误'
    ];

    protected $scene = [
        // 添加小节
        'addSection' => ['title','content','chapter_id','status'],
        // 修改小节
        'updateSection' => ['title','content','id','status'],
    ];
    
}